package com.zhq.blog.manage.domain.controller.product;



import javax.validation.Valid;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.zhq.blog.core.domain.product.PrizeExplain;
import com.zhq.blog.manage.domain.controller.BaseController;
import com.zhq.blog.manage.domain.controller.BossModel;

@Controller
@Scope("prototype")
@RequestMapping("/admin/product/prizeExplain/*")
public class PrizeExplainController extends BaseController {
	@RequestMapping(value="add")
	public BossModel add(){
		return createModel("admin/product/prizeExplain/explain").add("explain",context.getPrizeExplainRepository().findAll().get(0));
	}
	
	@RequestMapping(value="save",method = RequestMethod.POST)
	public BossModel save(@Valid final PrizeExplain prizeExplain, final BindingResult bindingResult, final ModelMap model, RedirectAttributes redirectPrizes){
		context.getPrizeExplainRepository().save(prizeExplain);
		return createModel("admin/product/prizeExplain/explain").add("explain", context.getPrizeExplainRepository().findAll().get(0));
	}

}
